﻿using System;
using UnityEngine;

// Token: 0x020002E9 RID: 745
[Serializable]
public class HsvColor
{
	// Token: 0x06001243 RID: 4675 RVA: 0x00094BA8 File Offset: 0x00092DA8
	public HsvColor(float hue, float saturation, float brightness)
	{
		if (hue < 0f || 360f < hue)
		{
			throw new ArgumentException("hueは0~360の値です。", "hue");
		}
		if (saturation < 0f || 1f < saturation)
		{
			throw new ArgumentException("saturationは0以上1以下の値です。", "saturation");
		}
		if (brightness < 0f || 1f < brightness)
		{
			throw new ArgumentException("brightnessは0以上1以下の値です。", "brightness");
		}
		this._h = hue;
		this._s = saturation;
		this._v = brightness;
	}

	// Token: 0x06001244 RID: 4676 RVA: 0x00094C44 File Offset: 0x00092E44
	public HsvColor(global::HsvColor src)
	{
		this._h = src._h;
		this._s = src._s;
		this._v = src._v;
	}

	// Token: 0x1700028D RID: 653
	// (get) Token: 0x06001245 RID: 4677 RVA: 0x00094C70 File Offset: 0x00092E70
	// (set) Token: 0x06001246 RID: 4678 RVA: 0x00094C78 File Offset: 0x00092E78
	public float H
	{
		get
		{
			return this._h;
		}
		set
		{
			this._h = value;
		}
	}

	// Token: 0x1700028E RID: 654
	// (get) Token: 0x06001247 RID: 4679 RVA: 0x00094C84 File Offset: 0x00092E84
	// (set) Token: 0x06001248 RID: 4680 RVA: 0x00094C8C File Offset: 0x00092E8C
	public float S
	{
		get
		{
			return this._s;
		}
		set
		{
			this._s = value;
		}
	}

	// Token: 0x1700028F RID: 655
	// (get) Token: 0x06001249 RID: 4681 RVA: 0x00094C98 File Offset: 0x00092E98
	// (set) Token: 0x0600124A RID: 4682 RVA: 0x00094CA0 File Offset: 0x00092EA0
	public float V
	{
		get
		{
			return this._v;
		}
		set
		{
			this._v = value;
		}
	}

	// Token: 0x0600124B RID: 4683 RVA: 0x00094CAC File Offset: 0x00092EAC
	public virtual void Copy(global::HsvColor src)
	{
		this._h = src._h;
		this._s = src._s;
		this._v = src._v;
	}

	// Token: 0x0600124C RID: 4684 RVA: 0x00094CD4 File Offset: 0x00092ED4
	public static global::HsvColor FromRgb(Color rgb)
	{
		float r = rgb.r;
		float g = rgb.g;
		float b = rgb.b;
		float num = Math.Max(r, Math.Max(g, b));
		float num2 = Math.Min(r, Math.Min(g, b));
		float hue = 0f;
		if (num == num2)
		{
			hue = 0f;
		}
		else if (num == r)
		{
			hue = (60f * (g - b) / (num - num2) + 360f) % 360f;
		}
		else if (num == g)
		{
			hue = 60f * (b - r) / (num - num2) + 120f;
		}
		else if (num == b)
		{
			hue = 60f * (r - g) / (num - num2) + 240f;
		}
		float saturation;
		if (num == 0f)
		{
			saturation = 0f;
		}
		else
		{
			saturation = (num - num2) / num;
		}
		float brightness = num;
		return new global::HsvColor(hue, saturation, brightness);
	}

	// Token: 0x0600124D RID: 4685 RVA: 0x00094DCC File Offset: 0x00092FCC
	public static Color ToRgb(float h, float s, float v)
	{
		return global::HsvColor.ToRgb(new global::HsvColor(h, s, v));
	}

	// Token: 0x0600124E RID: 4686 RVA: 0x00094DDC File Offset: 0x00092FDC
	public static Color ToRgb(global::HsvColor hsv)
	{
		float v = hsv.V;
		float s = hsv.S;
		float r;
		float g;
		float b;
		if (s == 0f)
		{
			r = v;
			g = v;
			b = v;
		}
		else
		{
			float num = hsv.H / 60f;
			int num2 = (int)Math.Floor((double)num) % 6;
			float num3 = num - (float)Math.Floor((double)num);
			float num4 = v * (1f - s);
			float num5 = v * (1f - s * num3);
			float num6 = v * (1f - s * (1f - num3));
			switch (num2)
			{
			case 0:
				r = v;
				g = num6;
				b = num4;
				break;
			case 1:
				r = num5;
				g = v;
				b = num4;
				break;
			case 2:
				r = num4;
				g = v;
				b = num6;
				break;
			case 3:
				r = num4;
				g = num5;
				b = v;
				break;
			case 4:
				r = num6;
				g = num4;
				b = v;
				break;
			case 5:
				r = v;
				g = num4;
				b = num5;
				break;
			default:
				throw new ArgumentException("色相の値が不正です。", "hsv");
			}
		}
		return new Color(r, g, b);
	}

	// Token: 0x0600124F RID: 4687 RVA: 0x00094EFC File Offset: 0x000930FC
	public static Color ToRgba(global::HsvColor hsv, float alpha)
	{
		Color result = global::HsvColor.ToRgb(hsv);
		result.a = alpha;
		return result;
	}

	// Token: 0x0400182C RID: 6188
	protected float _h;

	// Token: 0x0400182D RID: 6189
	protected float _s;

	// Token: 0x0400182E RID: 6190
	protected float _v;
}
